<?php
namespace Common\Model;
use Admin\Model\NewscateModel;
use Admin\Model\PhotocateModel;


class CommonModel {

    //修改显示字段
    static function status($list){
        foreach($list as $key=>$value){
            if($value['status']==10){
                $list[$key]['status']='新';
            }else if($value['status']==30){
                $list[$key]['status']='旧';
            }
            $list[$key]['create']=date('Y年m月d日',$value['create']);
            $list[$key]['update']=date('Y年m月d日',$value['update']);
        }
        return $list;
    }
//修改显示字段
    static function status1($list){
        foreach($list as $key=>$value){
            $list[$key]['create']=date('Y-m-d',$value['create']);

        }
        return $list;
    }

    //预约会员
    static function order($list){
        foreach($list as $key=>$value){
            if($value['status']==20){
                $list[$key]['status']='豪华';
            }else if($value['status']==40){
                $list[$key]['status']='别墅';
            }else if($value['status']==60){
                $list[$key]['status']='设计师';
            }
            $list[$key]['create']=date('Y年m月d日',$value['create']);
            $list[$key]['update']=date('Y年m月d日',$value['update']);
        }
        return $list;

    }

    //公告展示
    static function news($list){
        foreach($list as $key=>$value){
            if($value['status']==10){
                $list[$key]['status']='是';
            }else if($value['status']==30){
                $list[$key]['status']='否';
            }
            if($value['stick']==10){
                $list[$key]['stick']='是';
            }else if($value['stick']==30){
                $list[$key]['stick']='否';
            }
            $newscateModel=new NewscateModel();
            $list[$key]['news_cate']=$newscateModel->getname($value['news_cate']);
            $list[$key]['layout']=CommonModel::substr($value['layout']);
            $list[$key]['create']=date('Y年m月d日',$value['create']);
            $list[$key]['update']=date('Y年m月d日',$value['update']);
        }
        return $list;
    }

    //过滤修改内容
    static function filter($data,$list){
        $data=array_diff_assoc($data,$list);
        return $data;
    }


    //拼接图片路径
    static function substr($filename)
    {
        return substr($filename,0,4).'/'.substr($filename,4,2).'/'.substr($filename,6,2).'/'.$filename;
    }



    //photo后台展示
    static function photo($list){
        foreach($list as $key=>$value){
            if($value['status']==10){
                $list[$key]['status']='是';
            }else if($value['status']==30){
                $list[$key]['status']='否';
            }
            $photocateModel=new PhotocateModel();
            $list[$key]['photo_cate']=$photocateModel->getname($value['photo_cate']);
            $list[$key]['pic']=CommonModel::substr($value['pic']);
            $list[$key]['create']=date('Y年m月d日',$value['create']);
            $list[$key]['update']=date('Y年m月d日',$value['update']);
        }
        return $list;
    }

    //photo前台展示
    static function photo1($list){
        foreach($list as $key=>$value){

            $list[$key]['pic']=CommonModel::substr($value['pic']);

        }
        return $list;
    }

    static function photo2($list){
        $list['pic']=CommonModel::substr($list['pic']);
        return $list;
    }


}
